//
//  Network+API.h
//  YanXiuWang
//
//  Created by 招利 李 on 16/11/17.
//  Copyright © 2016年 小分队. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "Network+Upload.h"
//#import "Network+URL.h"

typedef NS_ENUM(NSUInteger, NetState) {
    NetStateComplete,
    NetStateLoading
};

@class GIFMaker, RequestNormal;
typedef void (^OnFailure)(NSError * _Nonnull error);
typedef void (^OnSuccess)(id _Nonnull response);
typedef GIFMaker * _Nonnull (^ShowStateGIF)(int style);
typedef GIFMaker * _Nonnull (^FailStateReload)(BOOL failNeedReload);
typedef GIFMaker * _Nonnull (^GIFStateView)(UIView * _Nullable view);
typedef GIFMaker * _Nonnull (^GIFStateText)(NSString * _Nullable text);
typedef GIFMaker * _Nonnull (^GIFStateColor)(UIColor * _Nullable color);
typedef __kindof RequestNormal * _Nonnull (^GIFStateObject)(NSObject * _Nonnull obj);

typedef RequestNormal * _Nonnull (^Failure)(OnFailure _Nonnull failureBlock);
typedef RequestNormal * _Nonnull (^Complete)();

#pragma mark - 通用规则
@interface RequestNormal (General)

/** http 请求完成时回调  */
@property (nonatomic, copy, readonly) Complete _Nonnull onResponse;
/** http 请求完成时回调  */
@property (nonatomic, copy, readonly) Complete _Nonnull onComplete;
/** http 请求失败时回调  */
@property (nonatomic, copy, readonly) Failure _Nonnull onFailure;

@property (nonatomic, copy, readonly) ShowStateGIF _Nonnull showGIF;

- (nonnull NSURLSessionTask *)onSuccess:(OnSuccess _Nonnull)successBlock;

- (nonnull NSURLSessionTask *)onTWSuccess:(OnSuccess _Nonnull)successBlock;

- (nonnull NSURLSessionTask *)onAPPLESuccess:(OnSuccess _Nonnull)successBlock;

- (nonnull NSURLSessionTask *)onSuccess:(nonnull NSObject *)target selector:(nonnull SEL)selector;

//- (nonnull NSURLSessionTask *)onYXWSuccess:(OnSuccess _Nonnull)successBlock;
//- (nonnull NSURLSessionTask *)onYXWSuccess:(nonnull NSObject *)target selector:(nonnull SEL)selector;

@end


@class UIImageGifView;
@interface GIFMaker : NSObject

@property (nonatomic, copy, readonly) GIFStateText _Nonnull withText;
@property (nonatomic, copy, readonly) GIFStateView _Nonnull maskView;
@property (nonatomic, copy, readonly) GIFStateColor _Nonnull backgroundColor;
@property (nonatomic, copy, readonly) GIFStateObject _Nonnull inObject;
@property (nonatomic, copy, readonly) FailStateReload _Nonnull hasReloadOnFail;


@end
